package com.hyt.it.ogt.kq.main.controller.gov;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hyt.common.apiInfor.ApiResponse;
import com.hyt.it.ogt.kq.common.gov.constant.ResponseCode;
import com.hyt.it.ogt.kq.service.gov.model.param.TestReportResultParam;
import com.hyt.it.ogt.kq.service.gov.model.vo.TestReportResultDetailVO;
import com.hyt.it.ogt.kq.service.gov.model.vo.TestReportResultVO;
import com.hyt.it.ogt.kq.service.gov.service.ITaskRoomTestReportService;
import com.hyt.model.PageParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSort;
import io.swagger.annotations.ApiSort;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 考场测试报告表 前端控制器
 * </p>
 *
 * @author huangyh
 * @since 2021-08-13
 */
@RestController
@Api(tags = "118.考场测试报告接口", value = "考场测试报告接口")
@ApiSort(value = 118)
@RequestMapping("/tk/kwTaskRoomTestReport")
@Slf4j
public class TaskRoomTestReportController {

    @Autowired
    ITaskRoomTestReportService taskRoomTestReportService;

    @ApiOperation(
            value = "18.1 查询考场测试报告分页数据",
            notes = "30000：成功"
    )
    @ApiOperationSort(value = 1)
    @RequestMapping(value = "/page", method = RequestMethod.GET)
    public ApiResponse<Page<TestReportResultVO>> getPage(PageParam<TestReportResultParam> pageParam, TestReportResultParam param) {
        log.debug("# 查询考场测试报告分页数据参数 ： {}", param);
        try {
            return ApiResponse.<Page<TestReportResultVO>>builder()
                    .code(ResponseCode.SUCCESS.getCode())
                    .data(taskRoomTestReportService.pageList(pageParam, param))
                    .build();
        } catch (Exception e) {
            log.error("# 查询考场测试报告分页数据异常:", e);
            return ApiResponse.<Page<TestReportResultVO>>builder()
                    .code(ResponseCode.TEST_REPORT_PAGE_QUERY_ERROR.getCode())
                    .build();
        }
    }

    @ApiOperation(
            value = "18.2 查询考场测试报详情数据",
            notes = "30000：成功"
    )
    @ApiOperationSort(value = 2)
    @RequestMapping(value = "/detail", method = RequestMethod.GET)
    public ApiResponse<TestReportResultDetailVO> detail(String testReportId) {
        log.debug("# 查询考场测试报详情数据参数 ： {}", testReportId);
        try {
            return ApiResponse.<TestReportResultDetailVO>builder()
                    .code(ResponseCode.SUCCESS.getCode())
                    .data(taskRoomTestReportService.detail(testReportId))
                    .build();
        } catch (Exception e) {
            log.error("# 查询考场测试报告详情数据异常:", e);
            return ApiResponse.<TestReportResultDetailVO>builder()
                    .code(ResponseCode.TEST_REPORT_DETAIL_QUERY_ERROR.getCode())
                    .build();
        }
    }

}
